package com.spic.business.train.year.controller;

import com.spic.business.train.year.domain.TrainPlanYearSearchRecord;
import com.spic.business.train.year.service.ITrainPlanYearSearchRecordService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 年度计划搜索记录框Controller
 *
 * @author yangjie
 * @date 2021-11-24
 */
@RestController
@RequestMapping("/train/year/search_record")
public class TrainPlanYearSearchRecordController extends BaseController
{
    @Autowired
    private ITrainPlanYearSearchRecordService trainPlanYearSearchRecordService;

    /**
     * 查询年度计划搜索记录框列表
     */
    @GetMapping("/list")
    public AjaxResult list(TrainPlanYearSearchRecord trainPlanYearSearchRecord)
    {
        List<TrainPlanYearSearchRecord> list = trainPlanYearSearchRecordService.selectTrainPlanYearSearchRecordList(trainPlanYearSearchRecord);

        return AjaxResult.success(list);
    }
    @GetMapping("/bySearch/{deptId}")
    public AjaxResult selectTrainPlanYearSearchRecordMap(@PathVariable("deptId") Long deptId)
    {
        return AjaxResult.success(trainPlanYearSearchRecordService.selectTrainPlanYearSearchRecordMap(deptId));
    }
    /**
     * 获取年度计划搜索记录框详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(trainPlanYearSearchRecordService.selectTrainPlanYearSearchRecordById(id));
    }

    /**
     * 新增年度计划搜索记录框
     */
    @PostMapping
    public AjaxResult add(@RequestBody TrainPlanYearSearchRecord trainPlanYearSearchRecord)
    {
        return toAjax(trainPlanYearSearchRecordService.insertTrainPlanYearSearchRecord(trainPlanYearSearchRecord));
    }

    /**
     * 修改年度计划搜索记录框
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TrainPlanYearSearchRecord trainPlanYearSearchRecord)
    {
        return toAjax(trainPlanYearSearchRecordService.updateTrainPlanYearSearchRecord(trainPlanYearSearchRecord));
    }

    /**
     * 删除年度计划搜索记录框
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(trainPlanYearSearchRecordService.deleteTrainPlanYearSearchRecordByIds(ids));
    }
}
